<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title><?php echo $title; ?></title>
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/admin/css/reset.css" />
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/css/common.css" />
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/admin/css/style.css" />
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>assets/js/prettyPhoto/prettyPhoto.css" />

<script src="<?php echo base_url(); ?>assets/js/jquery-1.7.1.min.js" type="text/javascript"></script>
<script type="text/javascript" src="<?php echo base_url('assets/js/prettyPhoto/jquery.prettyPhoto.js'); ?>"></script>
<script type="text/javascript" charset="utf-8">
	$(document).ready(function(){
		$("a[rel^='prettyPhoto']").prettyPhoto({
			deeplinking:false
		});
	});
</script>
<script type = "text/javascript">
$(document).ready(function(){
	//var emailExist=0;
	$("#frmAds").submit(function(e){
		var checkFrmAds = checkFields("#frmAds");
		if(checkFrmAds == 1){
			alert("empty required field");
			return false;
		}
	});

	$("#frmUsers").submit(function(){
		var checkFrmUsers = checkFields("#frmUsers");

		if(checkFrmUsers == 1){
			alert("empty required field");
			return false;
		}else{
			var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
			var validateEmail = checkValidateEmail($("input[name=email]").val());
			if(validateEmail==false){
				$("input[name=email]").addClass('error');
				alert("Invalid Email Address");return false;

			}else{
				$("input[name=email]").removeClass('error');
				if($("input[name=password]").val()!=$("input[name=cpassword]").val()){
					alert("Password did not match!");return false;
				}else{

					 $.ajax({
						url:'<?php echo base_url()?>admin/users/checkEmail/'+$("#form_action").val()+'/'+$("#userid").val(),
						type:'POST',
						data:'email='+$("input[name=email]").val(),
						success:function(response){

							if(parseInt(response)==1){
								$("#isExist").val('1');
							}else{
								$("#isExist").val('0');
							}
						}//end success
					});

				}

				if($("#isExist").val()=='1'){
						alert("Email Already Exist!");return false;
				}
			}

		}
	});



	return false;
});//end doc ready
function checkFields(formId){

	var error = 0;
		var required = $(formId).find('.required');
		required.each(function(index) {
			if (this.value.length == 0) {
				error = 1;
				$(this).addClass('error');

			}else{
				$(this).removeClass('error');
			}
		});
		if(error==1){
			//
			return error;
		}
}
function checkValidateEmail(email){
	var pattern = new RegExp(/^(("[\w-+\s]+")|([\w-+]+(?:\.[\w-+]+)*)|("[\w-+\s]+")([\w-+]+(?:\.[\w-+]+)*))(@((?:[\w-+]+\.)*\w[\w-+]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	return pattern.test(email);
}

</script>
</head>

<body>
	<div id="wrapper">
		<div id="top">
			<div id="header">
				<?php
				$title = "Dashboard";
				$ci =& get_instance();
				$controller = $ci->router->fetch_class();

				$resources = array(array("controller" => "dashboard", "title" => "Dashboard"),
			                      array("controller" => "users", "title" => "Profilers"),
								  array("controller" => "resellers", "title" => "Resellers"),
			                      array("controller" => "posts", "title" => "Wall Posts"),
			                      array("controller" => "messages", "title" => "Messages"),
			                      array("controller" => "advertisements", "title" => "Advertisements"),
			                      array("controller" => "payments", "title" => "Payments"),
			                      array("controller" => "testimonials", "title" => "Testimonials"),
//			                      array("controller" => "#", "title" => "Video Hints"),
			                      array("controller" => "product_packages", "title" => "Product Packages"),
			                      array("controller" => "settings", "title" => "Settings")
         		);
				foreach($resources as $resource){
					if( $controller == strtolower($resource["controller"]) ){
						$menutitle = $resource["title"];
						break;
					}
				}
				?>
				<div id="header-text"><?php echo $menutitle; ?></div>
			</div>
			<div id="message">
				Welcome Admin!  |  <a href="<?php echo base_url() ?>" target="_blank">View Site</a>  |  <a href="<?php echo site_url();?>admin/login/logout">Logout</a>
			</div>
		</div>
		<div class="clearfix"></div>
		<div id="content-wrap">
			<?php include('sidebar.php'); ?>
			<?php //$this->load->view('admin/sidebar'); ?>
			<div id="main-content">